package xyz.yuanjilu.utils;

import java.util.HashSet;
import java.util.Set;

public class StringUtils extends org.apache.commons.lang3.StringUtils{
	public static final String SEPARATOR=",";
	
	/**
	 * 去重重复关键字
	 * @param wordString 关键字字符串
	 * @param separator 分隔符
	 * @return
	 */
	public static  String distinctWord(String wordString,String separator){
		if (isBlank(wordString)) {
			return EMPTY;
		}
		if (isBlank(separator)) {
			separator=SEPARATOR;
		}
		
		String[] setString = wordString.split(separator);
		Set<String> set=new HashSet<String>();
		for (String string : setString) {
			set.add(string);
		}
		return join(set, separator);
	}
	/**
	 * 去重重复关键字
	 * @param wordString 关键字字符串
	 * @param separator 分隔符
	 * @return
	 */
	public static String distinctWord(String wordString){
		
		return distinctWord(wordString, SEPARATOR);
	}
	/**
	 * 去字符标点符号
	 * @param wordString 关键字字符串
	 * @param separator 分隔符
	 * @return
	 */
	public static String exceptSymbol(String string){
		if (string==null) {
			return null;
		}
		
		return string.replaceAll( "[\\pP+~$`^=|<>～｀＄＾＋＝｜＜＞￥×]" , "");  
	}
	
}
